# -*- coding: utf-8 -*-
from db.mysql import MysqlClient
from common.helper import Helper
class Arrangement( object ):
    def __init__(self):
        self.mysql = MysqlClient()
        self.name = "太平关爱今生重疾保障计划"

    def pullData(self, data={}):
        for item in Helper.selectData(self.name, self.mysql):
            if item["payType"] == "年缴":
                data["name"] = self.name
                data["company"] = "中国太平"
                data["year"] = item["year"]
                data["gender"] = "0" if item["gender"] == "F" else "0"
                data["money"] = str(int(int(item["money"])/10000)) + "w"
                data["expire"] = item["expire"]
                data["payType"] = item["payType"].replace("缴","交")
                data["interval"] = item["interval"] + "y"
                data["price"] = item["price"]
                Helper.mergeTable( self.name,self.mysql,data)
            else:
                if item["interval"]=="03":
                    interval = "36m"
                elif item["interval"] == "05":
                    interval = "60m"
                elif item["interval"] == "10":
                    interval = "120m"
                else:
                    interval = "240m"
                data["name"] = self.name
                data["company"] = "中国太平"
                data["year"] = item["year"]
                data["gender"] = "0" if item["gender"] == "F" else "0"
                data["money"] = str(int(int(item["money"]) / 10000)) + "w"
                data["expire"] = item["expire"]
                data["payType"] = item["payType"].replace("缴", "交")
                data["interval"] = interval
                data["price"] = item["price"]
                Helper.mergeTable(self.name, self.mysql, data)
